<?php


namespace App\Http\observer;


use App\Http\service\XcxService;
use App\Models\Image;
use App\Models\TurntableLog;

class TurntableLogObserver
{
    public function created(TurntableLog $turntableLog)
    {
        $scene="type=turntableLog&id=".$turntableLog["id"];
        $path=(new XcxService())->create_xcx_code($scene);
        TurntableLog::where("id",$turntableLog["id"])->update(["qrcode"=>$path]);
    }

    public function updated(TurntableLog $turntableLog)
    {
        if ($turntableLog["state"]==1){
            Image::del_data($turntableLog["qrcode"]);
        }
    }
}
